package com.rui.common.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置类
@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired //@Autowired 自动装配
    @Qualifier(value = "loginInterceptor")
    private HandlerInterceptor handlerInterceptor;
    @Override //代码规范，检查方法的正确性
    //拦截器注册
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration
                = registry.addInterceptor(handlerInterceptor);
        //拦截哪些请求
        registration.addPathPatterns("/**");
        //放行哪些请求
        registration.excludePathPatterns(
                "/login",//登录页面
                "/captcha",//验证码
                "/user/login",//登录请求
                "/user/loginout",//注销
                "/layui/**",
                "/lib/**",
                "/images/**",
                "/webjars/**",
                "/api/**",
                "/css/**",
                "/js/**"

        );
    }

}
